<?php
require __DIR__ . DIRECTORY_SEPARATOR . 'main.php';
main::run();

// $vpntester = new VpnTest\tester();

// $limit = 1000;
// $total_run_limit = 1200;
// if(isset($argv[1])){
//     $limit = (int)$argv[1];
//     isset($argv[2]) and $total_run_limit = (int) $argv[2];
// }

// $vpntester->run($limit, $total_run_limit);
// $vpntester->runOnline($limit, $total_run_limit);
// $proxy = '10.47.60.139:4433';
$proxy = '10.117.192.194:4433';
// $proxy = '10.51.43.253:4433';

// $limit = 100;
// $total_run_limit = 10;

// $vpntester->runOnline($limit, $total_run_limit, $proxy);
//$d = $vpntester->getAvaliableVpn($proxy);
//var_dump($d);
use HttpRequester\Curl;
use HttpRequester\CurlFacade;
use HttpRequester\CurlProxy;

// $url = 'http://sp0.baidu.com/9_Q4sjW91Qh3otqbppnN2DJv/pae/channel/data/asyncqury?cb=&appid=4001&com=yunda&vcode=&token=&nu=3101114660001&_=1475053650005';
// $options = [
//     CURLOPT_ENCODING => 'gzip, deflate, sdch',
//     CURLOPT_HTTPHEADER => [
//         'Accept-Language: zh-CN,zh;q=0.8',
//         'Cookie: BAIDUID=D3F1FE241F5E85E392059B047EC2142E:FG=1',
//         'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.132 Safari/537.36',
//         'Connection: keep-alive',
//         'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
//     ],
// ];
// $url = 'http://bhgit.com/appla/index.php?debug=1';
// var_dump(CurlFacade::get($url, $options));exit;

use Jmyp\JmypTester;
use Jd\JdTester;
use Taobao\TbTester;
use Wph\VipTester;
use Jd\JdLogin;
use JonnyW\PhantomJs\Client;
use JonnyW\PhantomJs\DependencyInjection\ServiceContainer;

use QL\QueryList;

// $phantomjs_bin = __DIR__.DIRECTORY_SEPARATOR.'bin'.DIRECTORY_SEPARATOR.'phantomjs.exe';
// $proc_dir = __DIR__.DIRECTORY_SEPARATOR.'phantomjs'.DIRECTORY_SEPARATOR.'php_phantomjs';
// $url = 'https://passport.jd.com/new/login.aspx';


// $serviceContainer = ServiceContainer::getInstance();

// $procedureLoader = $serviceContainer->get('procedure_loader_factory')->createProcedureLoader($proc_dir);

// $client = Client::getInstance();

// $client->getEngine()->setPath($phantomjs_bin);

// $client->setProcedure('jd_login');

// $client->getProcedureLoader()->addLoader($procedureLoader);

// $request  = $client->getMessageFactory()->createRequest($url, 'GET', 2000);

// $headers = [
//     'DNT' => 1,
//     'User-Agent' => '',
// ];

// $request->setHeaders($headers);

// $request->setUrl($url);

// $response = $client->getMessageFactory()->createResponse();

// $client->send($request, $response);

// var_dump($response, $client->getLog());

// $uname = '15921512039';
// $upass = 'yuanyongruKedymn';

// $obj = new JdLogin();
// // $obj->login($uname, $upass);
// $obj->test();

// $proxies = [
//    '10.47.60.139:4433',
//    '10.117.192.194:4433',
//    '10.51.43.253:4433',
//    ];
// $proxy = $proxies[array_rand($proxies)];
// CurlFacade::setInstance(new CurlProxy($proxy));
// CurlFacade::setOption(CURLOPT_TIMEOUT, 10);
// $url = 'https://httpbin.org/ip';
// $data = CurlFacade::get($url) or die('proxy error');
// var_dump($data, CurlFacade::getError());
// $obj = new JmypTester();
// $obj = new JdTester();
// $obj = new TbTester();
// $obj = new VipTester();
// var_dump($obj->get(), CurlFacade::getError());

use Jd\JdParser;
use Wph\VipParser;

use Taobao\TbParser;
use Jmyp\JmypParser;
use Taobao\TbUrlBuilder;

// $obj = new VipParser();
// $obj = new TbParser();
// $obj = new TbUrlBuilder();

// $obj = new JdParser();
$obj = new JmypParser();
// $type = 'jd';
// $type = 'vip';
// $type = 'taobao';
$type = 'jm';

// $obj->cookie_str = '_m_h5_tk=5c26be93a8db31d7cff459fea69b1425_1476677124352; _m_h5_tk_enc=6b0e6f2f176309d003b9074cff600229; v=0; cookie2=1698d744a5918a54c1ec471d2ea4a33c; _tb_token_=e8577a76a6530; cna=jCyLENx8rEkCAXTnml5+q6YA; wud=wud; ockeqeudmj=gcaBMy4%3D; _w_tb_nick=lsnha; imewweoriw=367vpgz8GOFBTBi7LOLGmuWdneYwssw6SGXPK%2BxiXuY%3D; munb=252939338; WAPFDFDTGFG=%2B4cMKKP%2B8PI%2BMKxltr9tzg%3D%3D; _w_app_lg=22; _w_al_f=1; uc3=sg2=VqoC7cwJwgkWSHHvb6WPC5lRmCbuAoc46o1tlzdo54Y%3D&nk2=D9Cfpl0%3D&id2=UU2w551eYFN6&vt3=F8dAS1808NpuOc3bqZ8%3D&lg2=UtASsssmOIJ0bQ%3D%3D; uc1=cookie14=UoWwIqlhcChRyw%3D%3D&cookie21=U%2BGCWk%2F7pY%2FF&cookie15=VFC%2FuZ9ayeYq2g%3D%3D; lgc=lsnha; uss=WqIowokXXwb0LU%2B0VdLm63YBj05bQDmRHh17gmhoLaeHuQQJ3bTI9qtrQDc%3D; tracknick=lsnha; sg=a84; cookie1=VqwQnUEKvm%2BPQkV24Q%2FRWUC0xIkoF88j4QedWhyBEtM%3D; ntm=0; unb=252939338; skt=912a972168c3a08f; t=0b26efe32abac3f0436671c1dc6bd825; _cc_=Vq8l%2BKCLiw%3D%3D; _nk_=lsnha; _l_g_=Ug%3D%3D; cookie17=UU2w551eYFN6; l=As/PENLrKv9xq1rQS4mD6gsQ33jZ9iMW; isg=AqurfqBMd_YX9KuiM9RM1Ln9Os-MDr9C9L4Zcx0ohepBvMketJCtkpRcZEYt; _m_user_unitinfo_=unit|unsz; _m_unitapi_v_=1476460846841';

// echo $obj->findInfoFromCookieStr(TbUrlBuilder::TOKEN_KEY);

$oid = '2411405283833893';

$waybill_no = '778845901837';
// echo $obj->buildQueryBoughtListUrl();

// echo $obj->buildQueryOrderDetailUrl($oid);

// echo $obj->buildQueryLogisticsUrl($oid);

// echo $obj->buildLogisDetailByWaybillUrl($oid);

// exit;

//vip_order_list
//vip_order_detail
//vip_wuliu

// $file_name = __DIR__.DIRECTORY_SEPARATOR.$type.'.txt';
// $file_name = __DIR__.DIRECTORY_SEPARATOR.$type.'_order_list.txt';
// $file_name = __DIR__.DIRECTORY_SEPARATOR.$type.'_order_detail.txt';
$file_name = __DIR__.DIRECTORY_SEPARATOR.$type.'_wuliu.txt';

$str = file_get_contents($file_name);
// var_dump($obj->parseOrderList($str));
// var_dump($obj->parseOrderDetail($str));
var_dump($obj->parseExpressInfos($str));
